home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / I-Z / MEdit_1.5.cpt / C.mcr < prev    next >
Text File  |  1986-04-18  |  4KB  |  250 lines

  1. *   'C' Macros file for Medit 1.3
  2. *   Frank Alviani
  3. *   5:11:30 PM  4/15/86
  4. *
  5.  
  6. * for use together with the following macros
  7. * 1
  8. "Save current Position/P" {
  9.     push;
  10. };
  11.  
  12. * 2
  13. * jumps back to the last saved position with macro 1
  14. * the stack can hold the last eight positions
  15. "Back to Position/B" {
  16.     select(L[,C[)!;
  17.     pop;
  18. };
  19.  
  20. * 3
  21. * Inserts blanks until current column lined up with position on stack
  22. "Line up/L" {
  23.     while NOT C: > C[ {
  24.         Insert (" ");
  25.     };
  26. };
  27.  
  28. * select from stacked position to here, clean up stack
  29. "Select to here/H" {
  30.     select (L],C] | L:,C:);
  31.     drop;
  32. };
  33.  
  34. "-" {};
  35.  
  36. * 5
  37. * puts an "if" statement at the current location
  38. "If/I" {
  39.     push;
  40.     Insert("if ()\t/* */\n");
  41.     call(3);
  42.     Insert(" { \n}");
  43.     pop;
  44.     Select(L.,C.+4);
  45. };
  46.  
  47. * 6
  48. * puts an "if else" statement at the current location
  49. "If else/E" {
  50.     push;
  51.     Insert("if ()\t/* */\n");
  52.     call (3);
  53.     Insert(" { \n}\n}");
  54. * on "else line", line up with "if"
  55.     Select(L.,C$-3|L.,C$);
  56.     Cut;
  57.     Insert("else\t/* */\n  { \n}");
  58.     Select(L$-6,C.+4);
  59.     drop;
  60. };
  61.  
  62. * 7
  63. * puts a "while" statement at the current location
  64. "While/W" {
  65.     push;
  66.     Insert ("while ()\t/* */\n");
  67.     call (3);
  68.     Insert(" { \n}");
  69.     pop;
  70.     Select(L.,C.+7);
  71. };
  72.  
  73. *
  74. * puts a "do" statement at the current location
  75. "Do/Q" {
  76.     Insert ("do");
  77.     push;
  78.     Insert (" {\n");
  79.     call (3);
  80.     Insert ("} while ();");
  81.     drop;
  82.     select (L.,C$-2);
  83. };
  84.  
  85. * 8
  86. * puts a "for" statement at the current location
  87. "For/R" {
  88.     push;
  89.     Insert ("for (;;)\t/* */\n");
  90.     call (3);
  91.     Insert (" { \n}");
  92.     pop;
  93.     Select(L.,C.+5);
  94. };
  95.  
  96. * 9
  97. * puts a switch" statement at the current location
  98. "Switch/S" {
  99.     push;
  100.     Insert ("switch ()\n");
  101.     call (3);
  102.     Insert (" { \n}");
  103.     drop;
  104.     select (L.-2, C$-1);
  105. };
  106.  
  107. * 10
  108. * puts a "case" phrase at the current location
  109. "Case/A" {
  110.     push;
  111.     Insert ("case :\n");
  112.     call (3);
  113.     Insert (" break;");
  114.     drop;
  115.     select (L.-1,C$-1);
  116. };
  117.  
  118. *
  119. * comments out current line with //
  120. "Comment out line//" {
  121.     select (L., 0);
  122.     Insert ("// ");
  123. };
  124.  
  125. "-" {};
  126.  
  127. * 12
  128. * jump to bottom of file
  129. "Bottom" {
  130.     SELECT(L$,C$)!;
  131. };
  132.  
  133. * 13
  134. * jump to top of file
  135. "Top" {
  136.     SELECT(0,0)!;
  137. };
  138.  
  139. * 14
  140. * ask for a line number to jump to and do it
  141. "Jump to Line/J" {
  142.     prompt("Goto Line",#0);
  143.     select(#0-1,0|#0-1,C$)!;
  144. };
  145.  
  146. * 15
  147. * replace the shortcut to the left of the cursor position with
  148. * the appropriate string. to define shortcuts write them at the
  149. * top of the window followed by the string to insert. use one line for
  150. * each shortcut. separate string and shortcut by a blank.
  151. * examples: (define them without an asterik at the start of the window)
  152. * ilm I like Macintosh
  153. * gb Good bye
  154. *
  155. * if you type 'ilm' and then press command-g this will replace
  156. * 'ilm' with 'I like Macintosh'. 'gb' will be replaced by 'Good bye'
  157. "Glossary/G" {
  158.     Select(L.,C<|L.,C.);
  159.     Push;
  160.     Set($0,$S);
  161.     Select(0,0);
  162.     Find($0);
  163.  
  164.     If L. < L[ And C. = 0{
  165.         Select(L.,C:+1|L.,C$);
  166.         Copy;
  167.         Pop;
  168.         Paste;
  169.     }
  170.     Else {
  171.         Pop;
  172.         Select(L:,C:);
  173.     };
  174. };
  175.  
  176. * 16
  177. * scroll one screen down
  178. * if you have a Mac+ or a numeric keypad you may use shift-cursor-down
  179. "Page Down/D" 272 {
  180. * get screen height
  181.     Set(#9, L>-L<-1);
  182.     Select(L>+#9,C.)!;
  183. };
  184.  
  185. * 17
  186. * scroll one screen up
  187. * if you have a Mac+ or a numeric keypad you may use shift-cursor-up
  188. "Page Up/U" 277 {
  189. * get screen height
  190.     Set(#9, L>-L<-1);
  191.     Select(L<-#9,C.)!;
  192. };
  193.  
  194. * 18
  195. * replace all 'real' tabs by blank strings
  196. * this is useful to convert 'Edit'- to 'MEdit'-files
  197. "Replace tabs" {
  198.     SELECT(0,0)!;
  199.     FIND("\9");
  200.     WHILE NOT L. = 0 OR NOT C. = 0 {
  201.         INSERT("\t");
  202.         FIND("\9");
  203.     };
  204. };
  205.  
  206. *19
  207. * redefines shift-BS to 'delete to end of line' 
  208. * instead of 'delete right char'
  209. 251 {
  210.     Select(L.,C.|L.,C$);
  211.     Clear;
  212. };
  213.  
  214. * 20
  215. * this macro moves to the END of the next line (option-return)
  216. 336 {
  217.     select (L.+1,C$)!;
  218. };
  219.  
  220. * the numbers define cursor keys on a Mac Plus / num Keypad
  221. * up
  222. 177 {
  223.     SELECT(L.-1,C.)!;
  224. };
  225.  
  226. * down
  227. 172 {
  228.     SELECT(L.+1,C.)!;
  229. };
  230.  
  231. * right
  232. 166 {
  233.     SELECT(L.,C.+1)!;
  234.     IF C. = C$ {
  235.         SELECT(L.+1,0)!;
  236.     };
  237. };
  238.  
  239. * left
  240. 170 {
  241.     SELECT(L.,C.-1)!;
  242.     IF C. = 0 {
  243.         SELECT(L.-1,0);
  244.         SELECT(L.,C$);
  245.     };
  246. }.
  247.  
  248.  
  249.